<script type="text/javascript"><!--//--><![CDATA[//><!--
	console.clear();
    
    var grid_reload = function() {
        $('#datagrid').datagrid('reload', $('#fm_search').serializeObject());
    };
    
    $(document).ready(function() {
    	$('#nama_karyawan').readonly();

		$('#fm_search').setupForm([
			{ name: 'id_karyawan_pk', type: 'lov', size: 'short', 
				onClearButton:function(){
					$(this).setval(''); 
					$('#nama_karyawan').setval('');
					grid_reload();
				},
				onActionButton:function(){ 
					LOVCoreKaryawan({ onSelect:function(row){ 
						$('#id_karyawan_pk').setval(row.id_karyawan_pk); 
						$('#nama_karyawan').setval(row.nama_karyawan); 
						grid_reload();
					} });
				}
			}
		]);
		
		$('#tgl_awal, #tgl_akhir').setDatePicker();
		$('#tgl_awal').setval('<?php echo date_format3(NOW, '01/MM/YYYY'); ?>');
		// $('#tgl_awal').setval('<?php echo date_format3(NOW, '01/10/2013'); ?>');
		$('#tgl_akhir').setval('<?php echo @date('t/m/Y'); ?>');
		
		// Setup Datagrid
		$('#datagrid').datagrid({  
			url:gs_path+'/'+controller+'/getdata_laporan', 
			queryParams: $('#fm_search').serializeObject(),
			height:405,
			// width:1000,
			// fitColumns:true,
			pagination:true,
			singleSelect:true,
			frozenColumns: [[
				//{ field : 'ck', checkbox:true, width: 40, align: 'center' },
				{ field : 'id_karyawan_pk', title : 'NIK', width : 100, sortable:true },
			]],
			columns:[[
				{ field : 'nama_karyawan', title : 'Nama Karyawan', width : 200, sortable:true },
				{ field : 'rapat', title : 'Rapat', width : 50, sortable:false, align:"right" },
				{ field : 'nilai_rapat', title : 'Nilai Rapat', width : 80, sortable:false, formatter:formatNumeric, align:"right" },
				{ field : 'piket', title : 'Piket', width : 50, sortable:false, align:"right"},
				{ field : 'nilai_piket', title : 'Nilai Piket', width : 80, sortable:false, formatter:formatNumeric, align:"right" },
				
			]],
			rownumbers: true
		});
        
        // Set Action Button
        var buttons = [	// ----- >> Download Button
			{label: 'Download', icon:'excel', onclick: function() { 
				$.messager.alert('Info','Fitur ini akan ada pada update berikutnya');
				/*setLoading(true);
				$.ajax({
					type: 'POST', 
					url: gs_path+'/'+controller+'/download/', cache: false, 
					data: jQuery.param( $('#fm_search').serializeArray().concat({ name:'sessid', value:sessid })),
					success: function(data) { 
						setLoading(false); 
						if(data!=''){ 
							alert(data); 
							return false; 
						} 
						document.getElementById('if_download').src='<?php echo base_url(); ?>app/download/?file=<?php echo _SESSID; ?>.xls&filename=data_pinjaman._NOW_.xls'; 
					},
					error: function(xhr, ajaxOptions, thrownError) { 
						setLoading(false); 
						var ls_message = ''; 
						var ls_logmessage = ''; 
						if (xhr.status == 0) { 
							ls_message = 'You are offline!!\n Please Check Your Network.'; 
						} else if (xhr.status == 404) { 
							ls_message = 'Requested URL not found.'; 
						} else if (xhr.status == 500) { 
							ls_message = 'Internal Server Error.';  
						} else if (thrownError == 'parsererror') { 
							ls_message = 'Error.\nParsing JSON Request failed.' 
						} else if (thrownError == 'timeout') { 
							ls_message = 'Request Time out.'; 
						} else { 
							ls_message = 'Unknow Error.\n' + xhr.responseText; 
						} $.messager.alert('&nbsp;',nl2br(ls_message),'error'); 
					}, 
					dataType: "html"
				});*/
			}} ];
        setAction(buttons);
		
		
		$('#fm_search').focusFirst();
    });
//--><!]]>
</script>

    
<div id="tb" style="padding:5px;height:auto">
    <div>
        <form id="fm_search" method="post" onsubmit="grid_reload(); return false;">
        	<table class="tb_form" style="margin-bottom:0px">
            <tr>
            	<td width="100">Karyawan</td>
                <td><input type="text" id="id_karyawan_pk" name="id_karyawan_pk" class="textfield short" /> <input type="text" id="nama_karyawan" name="nama_karyawan" class="textfield medium" /></td>
            </tr>
            <tr>
            	<td>Tgl. Absen</td>
                <td><input type="text" id="tgl_awal" name="tgl_awal" />_ &nbsp; <input type="text" id="tgl_akhir" name="tgl_akhir" /> 
                	<a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="grid_reload(); return false;">Search</a>
                    <!-- <a href="#" class="easyui-linkbutton" iconCls="icon-blank-file" onclick="$('#fm_search').resetForm(); return false;">Reset</a> -->
                    <input type="submit" style="display:none" />
                </td>
            </tr>
            </table>
        </form>
    </div>
</div>
<div id="datagrid" toolbar="#tb"></div>